/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;

import beans.product;
import com.mysql.jdbc.Statement;
import java.sql.ResultSet;

import java.sql.SQLException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author havn
 */
public class ProductObj {

    private connector con;

    public ProductObj() {
        con = new connector();
    }

    public Vector<product> list() {
        Vector<product> arr = new Vector<product>();
        try {
            Statement query = (Statement) con.getCon().createStatement();
            ResultSet rs = query.executeQuery("select * from product");
            while (rs.next()) {
                product prod = new product();
                prod.setId(rs.getInt("id"));
                prod.setName(rs.getString("name"));
                arr.add(prod);
            }
        } catch (SQLException ex) {
            Logger.getLogger(ProductObj.class.getName()).log(Level.SEVERE, null, ex);
        }
        return arr;
    }
}
